From d6dd76021226802adf5295b3243d6f2ae4fa5cc2 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Sun, 10 Mar 2024 17:59:58 +0000 Subject: refactor: Move all components to the top level directory --- .../lists/[listId]/components/DeleteListButton.tsx | 77 ---------------------- .../lists/[listId]/components/ListView.tsx | 25 ------- packages/web/app/dashboard/lists/[listId]/page.tsx | 4 +- 3 files changed, 2 insertions(+), 104 deletions(-) delete mode 100644 packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx delete mode 100644 packages/web/app/dashboard/lists/[listId]/components/ListView.tsx (limited to 'packages/web/app/dashboard/lists/[listId]') diff --git a/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx b/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx deleted file mode 100644 index 5303b217..00000000 --- a/packages/web/app/dashboard/lists/[listId]/components/DeleteListButton.tsx +++ /dev/null @@ -1,77 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { - Dialog, - DialogClose, - DialogContent, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "@/components/ui/dialog"; -import { Trash } from "lucide-react"; -import { useRouter } from "next/navigation"; -import { toast } from "@/components/ui/use-toast"; -import { api } from "@/lib/trpc"; -import { ActionButton } from "@/components/ui/action-button"; -import { useState } from "react"; -import { ZBookmarkList } from "@hoarder/trpc/types/lists"; - -export default function DeleteListButton({ list }: { list: ZBookmarkList }) { - const [isDialogOpen, setDialogOpen] = useState(false); - - const router = useRouter(); - - const listsInvalidationFunction = api.useUtils().lists.list.invalidate; - const { mutate: deleteList, isPending } = api.lists.delete.useMutation({ - onSuccess: () => { - listsInvalidationFunction(); - toast({ - description: `List "${list.icon} ${list.name}" is deleted!`, - }); - router.push("/"); - }, - onError: () => { - toast({ - variant: "destructive", - description: `Something went wrong`, - }); - }, - }); - return ( - - - - - - - - Delete {list.icon} {list.name}? - - - - Are you sure you want to delete {list.icon} {list.name}? - - - - - - deleteList({ listId: list.id })} - > - Delete - - - - - ); -} diff --git a/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx b/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx deleted file mode 100644 index 979b522f..00000000 --- a/packages/web/app/dashboard/lists/[listId]/components/ListView.tsx +++ /dev/null @@ -1,25 +0,0 @@ -"use client"; - -import BookmarksGrid from "@/app/dashboard/bookmarks/components/BookmarksGrid"; -import { ZBookmark } from "@hoarder/trpc/types/bookmarks"; -import { ZBookmarkListWithBookmarks } from "@hoarder/trpc/types/lists"; -import { api } from "@/lib/trpc"; - -export default function ListView({ - bookmarks, - list: initialData, -}: { - list: ZBookmarkListWithBookmarks; - bookmarks: ZBookmark[]; -}) { - const { data } = api.lists.get.useQuery( - { listId: initialData.id }, - { - initialData, - }, - ); - - return ( - - ); -} diff --git a/packages/web/app/dashboard/lists/[listId]/page.tsx b/packages/web/app/dashboard/lists/[listId]/page.tsx index 397a0f1e..006fd3ad 100644 --- a/packages/web/app/dashboard/lists/[listId]/page.tsx +++ b/packages/web/app/dashboard/lists/[listId]/page.tsx @@ -2,8 +2,8 @@ import { api } from "@/server/api/client"; import { getServerAuthSession } from "@/server/auth"; import { TRPCError } from "@trpc/server"; import { notFound, redirect } from "next/navigation"; -import ListView from "./components/ListView"; -import DeleteListButton from "./components/DeleteListButton"; +import ListView from "@/components/dashboard/lists/ListView"; +import DeleteListButton from "@/components/dashboard/lists/DeleteListButton"; export default async function ListPage({ params, -- cgit v1.2.3-70-g09d2